package com.huobao.yunying.utils;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.huobao.yunying.activitys.Act_Detail;
import com.huobao.yunying.activitys.Act_Search_Progect_List;
import com.huobao.yunying.activitys.Act_Select_String;
import com.huobao.yunying.activitys.Act_Shouyintai;
import com.huobao.yunying.huanxin.ui.ui.LoginActivity;
import com.huobao.zhangying.R;
import com.mylhyl.acp.Acp;
import com.mylhyl.acp.AcpListener;
import com.mylhyl.acp.AcpOptions;

import java.io.Serializable;
import java.util.List;

public class SkipUtils {

	public static void skipToSearchList(Context context, String cate_id, String keyword, String genre, String props, String brand, String price) {
		Intent intent = new Intent(context, Act_Search_Progect_List.class);
		intent.putExtra("cate_id", cate_id);
		intent.putExtra("keyword", keyword);
		intent.putExtra("genre", genre);
		intent.putExtra("props", props);
		intent.putExtra("brand", brand);
		intent.putExtra("price", price);
		context.startActivity(intent);
	}

	public static void seeDetail(Context context, String goodsId, String default_img) {
		Intent intent = new Intent(context, Act_Detail.class);
		intent.putExtra("id", goodsId);
		intent.putExtra("image", default_img);
		context.startActivity(intent);
	}

	public static void seeDetailnEWtASK(Context context, String goodsId, String default_img) {
		Intent intent = new Intent(context, Act_Detail.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.putExtra("id", goodsId);
		intent.putExtra("image", default_img);
		context.startActivity(intent);
	}

	public static void seeDetailForResult(Activity context, String goodsId, String default_img) {
		Intent intent = new Intent(context, Act_Detail.class);
		intent.putExtra("id", goodsId);
		intent.putExtra("image", default_img);
		context.startActivityForResult(intent, 1);
	}

	public static void Pay(Context context, String order_sn, String price, String content) {
		Intent intent = new Intent(context, Act_Shouyintai.class);
		intent.putExtra("order_sn", order_sn);
		intent.putExtra("price", price);
		intent.putExtra("content", content);
		context.startActivity(intent);
	}

	public static <T> void showSelectString(Activity activity, String title, List<T> datas, int requestCode, String showField) {
		Intent intent = new Intent(activity, Act_Select_String.class);
		intent.putExtra("title", title);
		intent.putExtra("data", (Serializable) datas);
		intent.putExtra("field", showField);
		activity.startActivityForResult(intent, requestCode);
	}

	public static void toChat(final Activity context, final Bundle b) {
		Acp.getInstance(context).request(new AcpOptions.Builder()
						.setPermissions(Manifest.permission.CAMERA,Manifest.permission.RECORD_AUDIO)
						.setDeniedMessage(context.getString(R.string.string_kefu_text))
                .setRationalMessage(context.getString(R.string.string_kefuquxnain__text))
						.build(),
				new AcpListener() {
					@Override
					public void onGranted() {
						Intent intent = new Intent(context, LoginActivity.class);
						if (b != null)
							intent.putExtras(b);
						context.startActivity(intent);
					}

					@Override
					public void onDenied(List<String> permissions) {
//						makeText(permissions.toString() + "权限拒绝");
					}
				});
	}
}
